/**
 * @Date 2023-02-21 14:00:07
 * @Remark
 */

// lib
// config
// script & methods & public
// store
import { userState } from "state/global";
import { state } from "./state";
// service
import { getDashboardBasicAdminDataService, getDashboardBasicUserDataService, getHotBorrowService, getHotOrderService } from "biz/Dashboard/service";
// interface
// 其它

// 获取首页数据
export async function getDashboardBasicData() {
  // 调用服务
  if (userState.isUser()) {
    let result = await getDashboardBasicUserDataService();
    if (result.payload) {
      state.userHomeData = result.payload;
    }
  } else {
    let result = await getDashboardBasicAdminDataService();
    if (result.payload && result.payload.copyCount) {
      state.adminHomeData = result.payload;
    }
  }

}
export async function getHotBorrow() {
  const result = await getHotBorrowService()
  if (result.payload) {
    state.hotBorrow = result.payload
  }
}
export async function getHotOrder() {
  const result = await getHotOrderService()
  if (result.payload) {
    state.hotOrder = result.payload
  }
}

export async function didMount() {
  getHotBorrow() 
  getHotOrder()
  getDashboardBasicData();
}
